function emptyfieldWH() {
	Ext.getCmp('ConfigWareHouse').getForm().reset();	

}


function getValueGridWarehouse(record) {
	Ext.getCmp('ButtonAddWh').setText('Update');
	var id  = record.get('WH_ID');
	if(Ext.getCmp('ConfigWareHouse').hidden == true) Ext.getCmp('ConfigWareHouse').toggleCollapse(true);
	Ext.Ajax.request({
	    method: "GET",
	    dataType: "json",
	    url: "./Services/DataMaster/Warehouse?WH_CODE="+id+"",
	    async: false	,
	    success: function(c) {
	    	var jsonResults= $.parseJSON(c.responseText);
	    	data = jsonResults.item[0];
	    	Ext.getCmp('ConfigWareHouse').getForm().setValues(data);
	        }
	    });	
}

function DeleteWarehouse() {
	var record=Ext.getCmp('table_Warehouse').getSelectionModel().getSelection();
	
	if (record.length > 0) {
		Ext.MessageBox.confirm('Delete', 'Are you sure?', function(btn) {
			if (btn == 'yes') {
				for (var i = 0; i < record.length; i++) {
					var id=record[i].get('WH_ID');
					var data={WH_ID: id};
					var url  = './Services/DataMaster/Warehouse/Delete';
	     	    	PostData(data,url,"Delete");
				}
				RefreshWarehouse();
			}
		});

	}else{
		Ext.MessageBox.show({
		 	title: 'WARNING!',
	        msg: 'No Data Selected',
	        icon: Ext.Msg.WARNING
	    });	
    
	}

}

function RefreshWarehouse(){
	Ext.getStore('Administration.Warehouse').getProxy().url = "./Services/DataMaster/Warehouse/List";
	Ext.getStore('Administration.Warehouse').load();
}

function SearchWarehouse(){
	var keyword = Ext.getCmp("keywordWarehouse").getValue();
	Ext.getStore('Administration.Warehouse').getProxy().url = "./Services/DataMaster/Warehouse/List?keyword="+keyword+"";
	Ext.getStore('Administration.Warehouse').load();
	
}